package cn.btks.databasehandler.handle.repository;

import cn.btks.databasehandler.handle.pojo.BackUpResult;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author lijun
 * @Date 2020/12/28 12:06
 */
@Repository
public interface BackUpResultRepository extends JpaRepository<BackUpResult,Long>, JpaSpecificationExecutor<BackUpResult> {

    /**
     * 根据备份配置ID查询备份结果
     * @param configId
     * @return
     */
    List<BackUpResult> findAllByConfigId(Long configId);

    /**
     * 根据ID删除备份结果
     * @param id
     * @return
     */
    @Modifying
    @Query(value = "delete from back_up_result where id = ?1",nativeQuery = true)
    int deleteResultById(Long id);
}
